package cn.lixu.feign;

import cn.lixu.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author LiXu
 * @date 2022/08/23 0023 18:42:59
 * OpenFeigh接口降级类
 */
@Component
public class OpenFeighFallBack implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L, "服务被熔断", "您的服务被熔断，请稍候再试");
            }
        };
    }
}
